package algorithm;

import java.util.Calendar;

public class CalendarAlgorithm {
	public static int compareDate(Calendar thisCal, Calendar otherCal) {
		if (thisCal.get(Calendar.YEAR) < otherCal.get(Calendar.YEAR))
			return -1;
		else if (thisCal.get(Calendar.YEAR) == otherCal.get(Calendar.YEAR)) {
			if (thisCal.get(Calendar.MONTH) < otherCal.get(Calendar.MONTH))
				return -1;
			else if (thisCal.get(Calendar.MONTH) == otherCal.get(Calendar.MONTH)) {
				if (thisCal.get(Calendar.DATE) < otherCal.get(Calendar.DATE))
					return -1;
				else if (thisCal.get(Calendar.DATE) == otherCal.get(Calendar.DATE))
					return 0;
				else
					return 1;
			}
			else
				return 1;
		}
		else
			return 1;
	}
	
	public static int compareTime(Calendar thisCal, Calendar otherCal) {
		if (thisCal.get(Calendar.HOUR_OF_DAY) < otherCal.get(Calendar.HOUR_OF_DAY))
			return -1;
		else if (thisCal.get(Calendar.HOUR_OF_DAY) == otherCal.get(Calendar.HOUR_OF_DAY)) {
			if (thisCal.get(Calendar.MINUTE) < otherCal.get(Calendar.MINUTE))
				return -1;
			else if (thisCal.get(Calendar.MINUTE) == otherCal.get(Calendar.MINUTE))
				return 0;
			else
				return 1;
		}
		else
			return 1;
	}
}
